package com.xinxing.city.recovery.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.xinxing.city.recovery.R;

import com.xinxing.city.recovery.databinding.ActivityOpsSet6Binding;
import com.xinxing.city.recovery.entitys.SetCategory;
import com.xinxing.city.recovery.utils.SharedPreferencesUtils;

import java.lang.reflect.Type;

public class OpsSet6Activity extends AppCompatActivity {
    private ActivityOpsSet6Binding binding;
    private SetCategory setCategory = new SetCategory();
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,R.layout.activity_ops_set6);
        setCategory.setBottomText("您可登录“开新回收”微信小程序查看您的环保金");
        setCategory.setTopTitle("恭喜您，完成交投");
        setCategory.setAutoOutTime("10");
        init();
        binding.setSetCategory(setCategory);
    }
    private void init(){
        String str = (String) SharedPreferencesUtils.getParam(this,"ops_finish","");
        if(!str.equals("")){
            Type dev = new TypeToken<SetCategory>() {}.getType();
            Gson gson = new Gson();;
            setCategory = gson.fromJson(str,dev);
        }
    }
    public void saveSub(View view) {
        Gson gson = new Gson();
        SharedPreferencesUtils.setParam(this, "ops_finish", gson.toJson(setCategory));
        Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show();
        OpsSet6Activity.this.finish();
    }
}